import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:sports_new/utils/utils.dart';
import 'package:sports_new/widgets/base/qkd_image.dart';

import '../../../resources/colours.dart';
import '../../../widgets/base/qkd_text.dart';
import '../../../widgets/gif.dart';

class ExpertLogo extends StatelessWidget {
  const ExpertLogo({
    super.key,
    required this.logo,
    this.inLive = false,
    this.size = 40,
    this.hasAuth,
    this.planCnt,
    this.authIcon,
    this.authSize});

  final String? logo;
  final bool? inLive;
  final bool? hasAuth;
  final double size;
  final int? planCnt;
  final String? authIcon;
  final double? authSize;

  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: AlignmentDirectional.center,
      clipBehavior: Clip.none,
      children: [
        Container(
          clipBehavior: Clip.antiAlias,
          decoration: BoxDecoration(
            border: Border.all(
              color: Colours.greyEE,
              width: 0.5,
              strokeAlign: BorderSide.strokeAlignOutside
            ),
            shape: BoxShape.circle
          ),
          child: QkdImage(
              width: size,
              height: size,
              shimmer: true,
              placeholder: Container(),
              errorWidget: Container(),
              imageUrl: logo ?? ''),
        ),
        if(inLive == true)
          Positioned(
            child: SizedOverflowBox(
              size: Size(size, size),
              child: GifWidget(
                width: size*1.35,height: size*1.35,
                asset: "expert_live.gif",
                duration: const Duration(milliseconds: 500)
              ),
            ),
          ),
        if(hasAuth == true)
          Positioned(
            bottom: 0,right: 0,
            child: Image.asset(
              Utils.getImgPath(authIcon??"expert_invite.png"),
              width: authSize??16,height: authSize??16
            ),
          ),
        if(planCnt.hasValue)
          Positioned(
            top: 0,
            right: 0,
            child: Container(
              width: 14,height: 14,
              alignment: Alignment.center,
              clipBehavior: Clip.antiAlias,
              decoration: BoxDecoration(
                gradient: const LinearGradient(
                  colors: [Colours.main,Color(0xFFEF366E)],
                ),
                shape: BoxShape.circle,
                border: Border.all(color: Colors.white,width: 1,strokeAlign: BorderSide.strokeAlignOutside)
              ),
              child: QkdText("$planCnt",
                needCenter: true,
                fontSize: 10,color: Colours.white
              )
            ),
          )
      ],
    );
  }
}
